package java_DesignPattern.BehavioralPattern.CommandPattern;

import java.util.Map;

/**
 * 命令订单类
 */
public class CommandOrder implements Command {

    //内聚厨师对象
    private Cs cs;

    //内聚订单对象
    private Order order;

    //构建命令订单
    public CommandOrder(Cs cs, Order order) {
        this.cs = cs;
        this.order = order;
    }

    @Override
    public void execute() {
        //获取到订单中的餐品
        Map<String, Integer> food = order.getFood();
        //遍历餐品，调用厨师制作食物
        for (Map.Entry<String, Integer> entry : food.entrySet()) {
            cs.makeFood(entry.getValue(), entry.getKey());
        }
    }
}
